package com.shiro.web.controller;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.shiro.web.model.Json;

@Controller
@RequestMapping("func")
public class FuncController {

	@RequiresRoles("ROLE_ADMIN")
	@RequestMapping("admin")
	@ResponseBody
	public Json admin() {
		Json json = new Json();
		json.setMsg("Shiro 注解权限测试 @RequiresRoles");
		return json;
	}

	@RequiresPermissions("user:view")
	@RequestMapping("method")
	@ResponseBody
	public Json method() {
		Json json = new Json();
		json.setMsg("Shiro 注解权限测试 @RequiresPermissions 查看权限");
		return json;
	}
	
	@RequestMapping("delete")
	@ResponseBody
	@RequiresPermissions("user:delete")
	public Json delete() {
		Json json = new Json();
		json.setMsg("Shiro 注解权限测试 @RequiresPermissions 删除权限");
		return json;
	}

}
